package com.imooc.courseprice.controller;

import com.imooc.courselist.entity.Course;
import com.imooc.courseprice.client.CourseListClient;
import com.imooc.courseprice.entity.CoursePrice;
import com.imooc.courseprice.service.CoursePriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 课程价格控制器
 */
@RestController
public class CoursePriceController {
    @Autowired
    CoursePriceService coursePriceService;
    @Autowired
    CourseListClient courseListClient;

    @GetMapping("/price")
    public Integer getCourse(Integer courseId) {
        CoursePrice coursePrice = coursePriceService.getCoursePrice(courseId);
        return coursePrice.getPrice();
    }

    @GetMapping("/coursesInPrice")
    public List<Course> getCourseListInPrice() {
        return courseListClient.courseList();
    }
}
